package sjtu.ist.warehouse4ws.action;
import java.util.ArrayList;
import java.util.List;

import sjtu.ist.warehouse4ws.model.Department;
import sjtu.ist.warehouse4ws.service.DepartmentService;

import com.googlecode.jsonplugin.annotations.JSON;
import com.opensymphony.xwork2.ActionSupport;

public class ShowCompanyListAction extends ActionSupport {

	private DepartmentService departmentService;
	private List<Department> companyList = new ArrayList<Department>();
	
	//获得Company列表
	public String showCompanyList(){
		this.companyList = departmentService.getCompanyList();
		return SUCCESS;
	}
	
	@JSON(name = "totalCompany")
	public int getTotalCompany() {
		return this.companyList.size();
	}

	@JSON(name = "Company")
	public List<Department> getCompanyList() {
		return this.companyList;
	}
	
	// 注入DepartmentService
	public void setDepartmentService(DepartmentService departmentService) {
		this.departmentService = departmentService;
	}
}